﻿using Kavaa.Core.Data;
using Kavaa.Modules.PortailMedical.Entity;
using System;
using System.Collections.Generic;
using System.Data.SqlClient;
using System.Linq;
using System.Text;

namespace Kavaa.Modules.PortailMedical.Datalayer
{
    class SpecialiteDAO
    {
        public static Specialites GetSpecialites()
        {
            Specialites Specialites = new Specialites();

            foreach (var row in SqlDaoAdapter.ExecuteReader(
                ConfigurationCache.DatabaseConnectionString,
                "[dbo].[sp_PortailMedical_GetSpecialites]"
           ))
            {
                Specialites.Add(new Specialite()
                {
                    Id = (row["SpecialiteId"] != DBNull.Value) ? Convert.ToInt32(row["SpecialiteId"]) : 0,
                    Name = (row["SpecialiteName"] != DBNull.Value) ? Convert.ToString(row["SpecialiteName"]) : null,
                });
            }

            return Specialites;
        }


        public static Actes GetActesSpecialite(int id_specialite)
        {
            Actes Actes = new Actes();

            foreach (var row in SqlDaoAdapter.ExecuteReader(
                ConfigurationCache.DatabaseConnectionString,
                "[dbo].[sp_PortailMedical_GetActesSpecialite]"
            , new List<SqlParameter>() { 
                new SqlParameter("@SpecialiteId", id_specialite),
               
               
            }))
            {
                Actes.Add(new Acte()
                {
                    Id = (row["ID"] != DBNull.Value) ? Convert.ToInt32(row["ID"]) : 0,
                    Name = (row["Name"] != DBNull.Value) ? Convert.ToString(row["Name"]) : null,
                

                });
            }

            return Actes;

        }
    }
}
